package com.kingdee.eas.xr.helper;

/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.


import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;

import com.kingdee.eas.xr.XRBillBaseInfo;

// Referenced classes of package com.kingdee.eas.ec.common:
//            EcConstant

public class EcStringHelper
{

    public EcStringHelper()
    {
    }

    public static String replace(String str, String regex, String replacement)
    {
        if(str == null)
            return null;
        else
            return str.replaceAll(regex, replacement);
    }

    public static boolean isEmptyStr(String str)
    {
        return str == null || str.length() == 0;
    }

    public static boolean isValueEquals(String str1, String str2)
    {
        if(str1 == null || str2 == null)
            return false;
        return str1.equalsIgnoreCase(str2);
    }

    public static String calVersion(String oldVersion)
    {
        String newVersion = null;
        String number = oldVersion.substring("1.".length());
        Integer value = new Integer(number);
        newVersion = (new StringBuilder()).append("1.").append(value.intValue() + 1).toString();
        return newVersion;
    }

    public static boolean isEmpty(String str)
    {
        return str == null || str.trim().length() == 0;
    }

    public static boolean isEmpty(Object obj)
    {
        return isEmpty(obj, false);
    }

    public static boolean isEmpty(Object obj, boolean isAllowZero)
    {
        if(obj instanceof String)
            return isEmpty((String)obj);
        if(obj instanceof Number)
            if(isAllowZero)
            {
                return obj == null;
            } else
            {
                Number num = (Number)obj;
                BigDecimal tempNum = new BigDecimal(num.toString());
                return 0 == BigDecimal.ZERO.compareTo(tempNum);
            }
        if(obj instanceof Map)
        {
            Map map = (Map)obj;
            return map.size() <= 0;
        }
        if(obj instanceof Collection)
        {
            Collection c = (Collection)obj;
            return c.size() <= 0;
        }
        if(obj instanceof XRBillBaseInfo)
        {
        	XRBillBaseInfo ei = ( XRBillBaseInfo)obj;
            return ei.getId() == null && ei.getNumber() == null;
        } else
        {
            return obj != null ? isEmpty(obj.toString()) : true;
        }
    }

    public static String getNumberByLen(int seq, int length)
    {
        String number;
        for(number = String.valueOf(seq); number.length() < length; number = (new StringBuilder()).append("0").append(number).toString());
        return number;
    }

    public static String subString(String str, int start, int end)
    {
        if(str == null)
            return null;
        else
            return str.substring(start, end <= str.length() ? end : str.length());
    }
}


/*
	DECOMPILATION REPORT

	Decompiled from: F:\qs\lib\industry\ec_common-server.jar
	Total time: 15 ms
	Jad reported messages/errors:
	Exit status: 0
	Caught exceptions:
*/